import pygame
from vector import vector
def getCollision(obj,obj2):
    if obj.getPos()[0]<=obj2.getPos()[1]&obj.getPos()[1]<=obj2.getPos()[1]&obj.getPos()[0]>=obj2.getPos()[0]+obj2.getWidth()&obj.getPos()[1]>=obj2.getPos()[1]+obj2.getHeight():
        return True
    else:
        return False
class i_object:
    def __init__(self,i_path,surface):
        self.i_object = pygame.image.load(i_path).convert()
        self.surface = surface
    def scale(self,width,height):
        self.i_object = pygame.transform.scale(self.i_object,(width,height))
    def draw(self,vec):
        self.surface.blit(self.i_object,vec.get())
class s_object:
    def __init__(self,window,color,width,height):
        self.width = width
        self.height = height
        self.windowSurface = window
        self.object = pygame.Surface((width,height))
        self.object.fill(color)
        self.pos = vector(200000000,200000000)
    def color(self,color):
        self.object.fill(color)
    def alpha(self,val):
        self.object.set_alpha(val)
    def draw(self,vec):
        self.pos = vec
        self.windowSurface.blit(self.object,vec.get())
    def getWidth(self):
        return self.width
    def getHeight(self):
        return self.height
    def getPos(self):
        return self.pos.get()
    def returnRect(self):
        return self.object.get_rect()
class r_object:
    def __init__(self,surface,color,width,height):
        self.surface = surface
        self.color = color
        self.width = width
        self.height = height
        vec = vector(200000,200000)
        self.vec = vector(200000,200000)
        self.object = pygame.draw.rect(self.surface,self.color,(vec.get()[0],vec.get()[1],self.width,self.height))
    def changeColor(self,color):
        self.color = color
    def draw(self,vec):
        self.object = pygame.draw.rect(self.surface,self.color,(vec.get()[0],vec.get()[1],self.width,self.height))
        self.vec = vec
    def getWidth(self):
        return self.width
    def getHeight(self):
        return self.height
    def getVector(self):
        return self.vec
    def getPos(self):
        return self.vec.get()
    def returnRect(self):
        return self.object
class text:
    def __init__(self,screen,text,color):
        self.screen = screen
        self.text = text
        self.color = color
        self.size = 20
    def color(self,color):
        self.color = color
    def size(self,size):
        self.size = size
    def draw(self,vec):
        font = pygame.font.SysFont("Courier New",self.size)
        ren = font.render(self.text,1,self.color)
        self.screen.blit(ren,vec.get())
    def getWidth(self):
        return len(self.text)*self.size
class line:
    def __init__(self,screen,color,start_pos,end_pos):
        self.width = 3
        self.color = color
        self.screen = screen
        self.body = pygame.draw.line(screen,self.color, start_pos.get(), end_pos.get(), self.width)
    def color(self,color):
        self.color = color
    def width(self,val):
        self.width = val
    def draw(self,start_pos,end_pos):
        self.pos = start_pos
        self.body = pygame.draw.line(self.screen,self.color, start_pos.get(), end_pos.get(), self.width)
    def returnRect(self):
        return self.body
    def getPos(self):
        return self.pos.get()
